package com.ufind.common.enums;

/**
 * 数据库中记录状态的枚举
 * Created by xuliugen on 16/1/10.
 */
public enum ERecordState {

    VALID(0, "有效"),
    INVALID(1, "无效");

    public Integer code;
    public String value;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    ERecordState(Integer value, String desc) {
        this.code = value;
        this.value = desc;
    }

    public static ERecordState getTypeByVal(Integer value) {
        ERecordState defaultState = VALID;
        for (ERecordState eRecordState : ERecordState.values()) {
            if (eRecordState.code.equals(value)) {
                return eRecordState;
            }
        }
        return defaultState;
    }

    public static String getDescByVal(Integer value) {
        return getTypeByVal(value).value;
    }

}
